function lTrim(checkValue) {
	returnValue = "";
// Find lTrim value
	for (i = 0 ; i < checkValue.length ; i++) {
		if (checkValue.substr(i, 1) != " ") {
			returnValue = checkValue.substring(i, checkValue.length);
			break;
		}
	}
	return returnValue;
}


function rTrim(checkValue) {
	returnValue = "";
// Find lTrim value
	for (i = checkValue.length-1 ; i >= 0 ; i--) {
		if (checkValue.substr(i, 1) != " ") {
			returnValue = checkValue.substring(0, i+1);
			break;
		}
	}
	return returnValue;
}


function trim(checkValue) {
// Find trim value from lTrim and rTrim function
	returnValue = lTrim(checkValue);
	returnValue = rTrim(returnValue);
	return returnValue;
}


function toFloat (checkValue) {
	var returnValue = true; // Variable for return value
	var floatValue = ""; // Variable for keep float value in form of string

	deci = checkValue.split(".");
	if (deci.length <= 2) {
		intArray = deci[0].split(",");
		floatValue = "";
		for (i=0; i<intArray.length; i++) {
			floatValue += intArray[i];
		}
		if (floatValue == parseFloat(floatValue)) {
			if (deci.length == 2) {
				if (deci[1] == parseInt(parseFloat(deci[1]))) {
					floatValue += "."+deci[1];
				} else returnValue=false;
			}
		} else returnValue=false;
	} else returnValue=false;

	if (returnValue) {
		returnValue = parseFloat(floatValue);
	}

	return returnValue;
}

function formatFloat (floatValue, minFraction, maxFraction, haveComma, round) {
// Set default value for run function
	var returnValue = ""; // Variable for return value
	var defaultMinFraction = 2; // Default fraction digits of float value
	var defaultMaxFraction = 2; // Default fraction digits of float value
	var defaultHaveComma = "no"; // Default comma in float value
	var defaultRound = "normal"; // Default comma in float value

// Check value of arguments and assign appropriate value
	minFraction = (minFraction == undefined || minFraction < 0) ? defaultMinFraction : minFraction ;
	maxFraction = (maxFraction == undefined || maxFraction < 0) ? defaultMaxFraction : maxFraction ;
	haveComma = (haveComma == undefined || haveComma == "") ? defaultHaveComma : haveComma ;
	round = (round == undefined || round == "") ? defaultRound : round ;

	floatArray = floatValue.split(".");
// Calculate round up, round down, normal value
	if (floatArray.length == 2) {
		if (floatArray[1].length > maxFraction) {
			tempValue = parseFloat(floatValue);
			addValue = "0.";
			for (i=0; i<maxFraction-1; i++){
				addValue += "0";
			}
			addValue += "1";
			if (round.toLowerCase() == "normal") {
				if (parseInt(floatArray[1].charAt(maxFraction)) >= 5) {
					floatValue = ""+(tempValue+parseFloat(addValue));
					floatArray = floatValue.split(".");
				}
			} else if (round.toLowerCase() == "up") {
				floatValue = ""+(tempValue+parseFloat(addValue));
				floatArray = floatValue.split(".");
			} else if (round.toLowerCase() == "down") {
			}
		}
	}
// Find integer with comma
	commaValue = floatArray[0];
	if (haveComma.toLowerCase() == "yes") {
		commaValue = "";
		for (i=floatArray[0].length-1; i>=0; i--){
			commaValue = floatArray[0].charAt(i)+commaValue;
			if (i%3 == floatArray[0].length%3 && i != 0) {
				commaValue = ","+commaValue;
			}
		}
	}

// Find fraction digits
	fractionValue = "";
	if (floatArray.length == 2) {
		if (floatArray[1].length > maxFraction) {
			numFraction = maxFraction;
			for (i=0; i<maxFraction; i++){
				fractionValue += floatArray[1].charAt(i);
			}
		} else if (floatArray[1].length < minFraction) {
			numFraction = minFraction;
			fractionValue = floatArray[1];
			for (i=0; i<(minFraction - floatArray[1].length); i++){
				fractionValue += "0";
			}
		} else {
			numFraction = floatArray[1].length;
			fractionValue = floatArray[1];
		}
	} else {
		numFraction = minFraction;
		for (i=0; i<numFraction; i++) {
			fractionValue += "0";
		}
	}

// Find value for show
	if (numFraction > 0) {
		returnValue = commaValue + "." + fractionValue;
	} else {
		returnValue = commaValue;
	}

	return returnValue ;
}